feat: adds AI agent detection to auto-switch to JSON output#4938
Closed
pushpak1300 wants to merge 29 commits intophpstan:2.1.xfrom
Closed
feat: adds AI agent detection to auto-switch to JSON output#4938pushpak1300 wants to merge 29 commits intophpstan:2.1.xfrom
pushpak1300 wants to merge 29 commits intophpstan:2.1.xfrom
Conversation
Automatically detects undocumented parameters in conf/parametersSchema.neon and creates a draft PR on phpstan/phpstan with documentation updates. Triggers on push to 2.2.x when the schema changes, or manually. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use github.event.before for push diffs to handle multi-commit pushes. Add explicit else branch for manual dispatch to check entire schema. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These parameters exist purely to be toggled by rule levels and are not configured by users directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The safe-output patch was trying to create the file as new, but it already exists in phpstan/phpstan. Add a pre-step that fetches and commits the file so the agent's edits produce a modification patch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of using safe-outputs create-pull-request (which generates patches that fail on cross-repo applies), checkout phpstan/phpstan to __phpstan-website/ subdirectory, edit config-reference.md in place, and push branch + create PR via bash/gh CLI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The gh-aw framework runs git commands in the workspace root expecting a git repository. Without checking out phpstan-src first, the "Configure Git credentials" step fails with "not a git repository". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The parametersSchema.neon has nested structure() blocks like exceptions.check.* and cache.*. The agent was only looking at top-level parameters and missing nested ones like throwTypeCovariance and tooWideImplicitThrowType. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x. |
Author
|
Closing in favor of a new PR targeting 2.1.x with the correct head branch. |
pushpak1300
added a commit
to pushpak1300/phpstan-src
that referenced
this pull request
Feb 15, 2026
Adds helgesverre/toon and creates ToonErrorFormatter that outputs in TOON (Token-Oriented Object Notation) format. When an AI agent is detected, PHPStan now outputs in TOON instead of JSON, reducing token consumption while remaining machine-parseable. Follows up on phpstan#4938.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds AI agent detection that automatically switches PHPStan to JSON error format when executed within Claude Code, Cursor, Gemini CLI, Codex, OpenCode, Augment, Replit, or Devin.
Why:
The default PHPStan output is designed for humans - colorful tables, progress bars with animations, and formatted summaries. AI agents need something different: structured JSON they can reliably parse, unambiguous error details with file paths and line numbers, minimal output that saves context window and reduces token cost, and no progress bar animations that waste tokens on redraw noise.
How it works:
CLAUDECODE/CLAUDE_CODEenvironment variableCURSOR_TRACE_ID/CURSOR_AGENTGEMINI_CLI,CODEX_SANDBOX,AI_AGENT, etc.)shipfastlabs/agent-detectorand automatically switches to JSON format + suppresses progress bar animations - no flags neededOutput:
{"totals":{"errors":0,"file_errors":1},"files":{"/path/to/file.php":{"errors":1,"messages":[{"message":"Error message","line":10,"ignorable":true,"identifier":"error.id"}]}},"errors":[]}Explicit
--error-format=tableor configerrorFormat: tablealways takes priority over agent detection.related laravel/pint#415